<?php
class malbumpicture extends CI_Model{
	var $albumpic = "album_picture";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_albumpic,$id_album,$nama_albumpic,$date_albumpic,$file_albumpic,$description_albumpic)
	{
		$this->id_albumpic = $id_albumpic;
		$this->id_album = $id_album;
		$this->nama_albumpic = $nama_albumpic;
		$this->date_albumpic = $date_albumpic;
		$this->file_albumpic = $file_albumpic;
		$this->description_albumpic = $description_albumpic;
	}
	
	function getList($id_album,$page,$offset){
		$this->db->where('id_album', $id_album);
		$query = $this->db->get($this->albumpic,$page,$offset);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getComboList(){
		$query = $this->db->get($this->albumpic);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{	
		$arrayData = array(
			'id_albumpic'=>$this->id_albumpic,
			'id_album'=>$this->id_album,
			'nama_albumpic'=>$this->nama_albumpic,
			'date_albumpic'=>$this->date_albumpic,
			'file_albumpic'=>$this->file_albumpic,
			'description_albumpic'=>$this->description_albumpic
		);
		return $this->db->insert($this->albumpic, $arrayData);
	}
	
	function update($id_albumpic)
	{
		$arrayData = array(
			'id_album'=>$this->id_album,
			'nama_albumpic'=>$this->nama_albumpic,
			'date_albumpic'=>$this->date_albumpic,
			'file_albumpic'=>$this->file_albumpic,
			'description_albumpic'=>$this->description_albumpic
		);
		$this->db->where('id_albumpic', $id_albumpic);
		return $this->db->update($this->albumpic, $arrayData);
	}
        
	function remove($id_albumpic)
	{
		$this->db->where('id_albumpic', $id_albumpic);
		return $this->db->delete($this->albumpic);
	}	
	
	function detail($id_albumpic)
	{
		$this->db->where('id_albumpic', $id_albumpic);
		$query = $this->db->get($this->albumpic);	
		return $query->result_array();
	}
	
	function getListSearch($name){
		$this->db->like('nama_albumpic',$name);
		$query = $this->db->get($this->albumpic);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getForWeb($id_album)
	{
		$this->db->where('id_album', $id_album);
		$query = $this->db->get($this->albumpic);	
		return $query->result_array();
	}
}
?>